package annotations;

import java.lang.reflect.Method;

import annotations.api.ControlledObject;
import annotations.api.StartObject;
import annotations.api.StopObject;

public class Main
{
    public static void main(String[] args) throws ClassNotFoundException
    {
        Class<?> class1 = Class.forName("annotations.Cookies");
        if (!class1.isAnnotationPresent(ControlledObject.class))
        {
            System.out.println("Annotation is not presentfor class - " + class1.getCanonicalName());
        }
        else
        {
            boolean hasStart = false;
            boolean hasStop = false;
            Method[] method = class1.getMethods();
            for (Method md : method)
            {
                if (md.isAnnotationPresent(StartObject.class))
                {
                    hasStart = true;
                }
                if (md.isAnnotationPresent(StopObject.class))
                {
                    hasStop = true;
                }
                if (hasStart && hasStop)
                {
                    break;
                }
            }
            System.out.println("Start annotaton  - " + hasStart + ";  Stop annotation  - " + hasStop);
        }
    }
}
